// templates/deliver/pages/print_after_sales/print_after_sales.js
import Toast from '@vant/weapp/toast/toast'
import { userRequest } from '../../../../utils/util'
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        order_no: '',
        access_token: ''

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        console.log(options.order_no)
        const order_no = options.order_no;
        let access_token = app.session.access_token
        this.setData({
            order_no,
            access_token,
        })

    },

    async getGoodsSummary() {
        const header = {
            'Content-Type': 'application/json',
            'x-api-key': this.data.access_token
        }
        const data = {
            order_no: this.data.order_no,
            print: true
        }
        const url = app.globalData.API + '/delivery/index/print-sales'
        try {
            wx.showLoading({
                title: '正在打印...'
            })
            const response = await userRequest(url, 'POST', data, header)
            console.log(response)
            wx.hideLoading()
            if (response.code === 200) {
                Toast.success('打印成功');
            }
        } catch (e) {
            console.log(e)
        }
    },
    getafterorder() {
        wx.navigateTo({
            url: '/templates/deliver/pages/waitingReview/waitingReview',
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {
        wx.reLaunch({
            url: '/templates/deliver/pages/index/index'
        })
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})